package com.xl.checkshake

import android.os.CountDownTimer
internal class XLock(private var time: Long) {

    @Volatile
    private var islock: Boolean = false

    fun lock() {
        islock = true
        countDownTimer.cancel()
        countDownTimer.start()
    }

    fun unlock() {
        islock = false
    }

    fun islock(): Boolean {
        return islock
    }

    private val countDownTimer: CountDownTimer = object : CountDownTimer(1000, 1000 * time) {
        override fun onTick(millisUntilFinished: Long) {
        }

        override fun onFinish() {
            unlock()
        }
    }

}